//清除全局样式
import 'reset-css'
//顶部进度条样式
import 'nprogress/nprogress.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { permissionDirective,roleDirective } from '@/directives/PermissionDirective';

import App from './App.vue'
import {router} from './router'

//注册全局图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

//加载sysConfigStore
import { useSysConfigStore } from "./stores/sysConfig";

// /* import the fontawesome core */
// import { library } from '@fortawesome/fontawesome-svg-core'
// /* import font awesome icon component */
// import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
// /* import specific icons */
// import { fas } from '@fortawesome/free-solid-svg-icons'
// /* add icons to the library */
// library.add(fas)

const app = createApp(App)

const pinia = createPinia()

app.use(pinia)
pinia.use(piniaPluginPersistedstate)

//权限和角色自定义指令
app.directive('permission',permissionDirective)
app.directive('role',roleDirective)

//加载动态路由
const sysConfig = useSysConfigStore()
await sysConfig.addRoute()

app.use(router)

// //注册图标库
// app.component('font-awesome-icon', FontAwesomeIcon)

app.mount('#app')

//注册全局图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
